<template>
  <view class="related-major">
    <view class="title-img-box">
      <image class="title-img" :src="partTextImgUrl" />
    </view>
    <view class="content-wrapper">
      <view class="content">
        <view class="desc-container">
          <view class="desc-item" v-for="item in dataItem" :key="item">
            <view class="title-box">
              <view class="line-block"></view>
              <view class="title">{{ item.titleList.join('、') }}</view>
            </view>
            <view class="desc-content">
              {{ item.desc }}
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    dataItem: {
      type: Array,
      default: () => []
    }
  },
  watch: {
    dataItem: {
      handler(newVal, oldVal) {
        newVal.forEach((item) => {
          const temp = [];
          item.title.forEach((subItem) => {
            temp.push(subItem.label);
          });
          item.titleList = temp;
        });
      },
      deep: true,
      immediate: true
    }
  },
  data() {
    return {
      partTextImgUrl:
        this.$imgBaseSelf + 'career/careerAssessNewImg/11_title.png?v=1'
    };
  },
  mounted() {
    uni
      .createSelectorQuery()
      .in(this)
      .select('.related-major')
      .boundingClientRect((rect) => {
        this.$emit('listenRect', rect);
      })
      .exec();
  }
};
</script>

<style lang="scss" scoped>
.related-major {
  margin-top: 48rpx;
  position: relative;
  width: 100%;
  .title-img-box {
    display: flex;
    .title-img {
      height: 112rpx;
      width: 405rpx;
    }
  }

  .content-wrapper {
    margin: -14rpx 32rpx 0 32rpx;
    background: #fff;
    border-radius: 0 20rpx 0rpx 0rpx;
    .content {
      padding: 53rpx 42rpx 42rpx 42rpx;

      background: linear-gradient(0deg, #ffffff 0%, #fbdefe 100%) no-repeat;
      border-radius: 0 20rpx 0rpx 0rpx;
      border: 1px solid #ffffff;
      background-size: 100% 83rpx;
      .desc-container {
        .desc-item {
          margin-top: 46rpx;
          &:first-child {
            margin-top: 16rpx;
          }
          .title-box {
            display: flex;
            .line-block {
              width: 24rpx;
              height: 20rpx;
              margin-top: 12rpx;
              flex-shrink: 0;
              background: linear-gradient(to right, #d290e4, #fff);
              margin-right: 12rpx;
            }
            .title {
              font-weight: 600;
              font-size: 30rpx;
              color: #bf44e2;
            }
          }
          .desc-content {
            margin-top: 20rpx;
            margin-left: 34rpx;
            width: 565rpx;
            font-size: 28rpx;
            color: #555555;
            line-height: 48rpx;
          }
        }
      }
    }
  }
}
</style>
